package com.naiterui.ehp.bs.doctor.fegin;

import java.util.List;
import java.util.Map;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import com.naiterui.ehp.bp.bo.esign.DigitalCertificateBO;
import com.naiterui.ehp.bp.bo.esign.EsignDoctorBO;
import com.naiterui.ehp.bp.bo.esign.EsignNoSecretBO;
import com.naiterui.ehp.bp.bo.esign.NoSecretParamBO;
import com.naiterui.ehp.bp.bo.esign.PreSignResultBO;
import com.naiterui.ehp.bp.bo.esign.WillTypeBO;
import com.naiterui.ehp.bp.support.config.FeignConfiguration;
import com.naiterui.ehp.bp.support.exception.BusinessException;

/**
 * @author guoyongxiang
 * @date 2019/12/3 16:23
 * @since 1.0.0
 */
@FeignClient(name = "adEsign", url = "${ehp.domain.esign}", configuration = FeignConfiguration.class)
public interface EsignFeginClient {

    /**
     * 创建电子签名医生账户
     *
     * @param userId
     *
     * @return
     */
    @PostMapping("inner/dr/esign/doctor/add")
    void esignDoctorAdd(@RequestParam("userId") Long userId, @RequestParam("name") String name, @RequestParam("idCard") String idCard, @RequestParam("phone") String phone,
                        @RequestParam("hospital") String hospital, @RequestParam("sealImagePath") String sealImagePath, @RequestParam("pwd") String pwd) throws BusinessException;

    /**
     * 更新医师电子签名手机号码
     * @param userId
     * @param phone
     * @throws BusinessException
     */
    @PostMapping("inner/dr/esign/doctor/update/phone")
    void esignDoctorUpdatePhone(@RequestParam("doctorId") Long doctorId, @RequestParam("phone") String phone) throws BusinessException;

    /**
     * 获取实名认证验证码
     *
     * @param name
     * @param phone
     * @param idCard
     *
     * @throws BusinessException
     */
    @PostMapping("inner/dr/esign/realname/code")
    void getRealnameCode(@RequestParam("name") String name, @RequestParam("phone") String phone, @RequestParam("idCard") String idCard) throws BusinessException;

    /**
     * 实名认证回填校验
     *
     * @param phone
     * @param code
     *
     * @throws BusinessException
     */
    @PostMapping("inner/dr/esign/realname/check")
    Boolean checkRealnameByCode(@RequestParam("phone") String phone, @RequestParam("code") String code)
        throws BusinessException;

    /**
     * 获取签名信息
     *
     * @param doctorId
     *
     * @throws BusinessException
     */
    @PostMapping("inner/dr/esign/info")
    EsignDoctorBO getEsignInfo(@RequestParam("doctorId") Long doctorId) throws BusinessException;

    /**
     * 获取医网信签名账号配置
     *
     * @throws BusinessException
     */
    @PostMapping("inner/common/ywx/sign/config")
    Map<String, String> getYwxSignConfig() throws BusinessException;

    /**
     * 意愿签署列表
     * @return
     * @throws BusinessException
     */
    @PostMapping("/inner/dr/will/types")
    List<WillTypeBO> getWillTypes(@RequestParam("doctorId")Long doctorId) throws BusinessException;

    /**
     * 更新药师意愿签署方式
     * @throws BusinessException
     */
    @PostMapping("/inner/dr/will/type/update")
    void updateWillType(@RequestParam("doctorId")Long doctorId, @RequestParam("willType")String willType) throws BusinessException;

    /**
     * 更新药师签名密码
     * @param doctorId
     * @param password
     * @throws BusinessException
     */
    @PostMapping("/inner/dr/password/update")
    void updatePasswd(@RequestParam("doctorId") Long doctorId, @RequestParam("password") String password) throws BusinessException;

    /**
     * 获取是否设置免密
     * @param doctorId 医生id
     * @return 0.未设置 1.已设置
     * @throws BusinessException
     */
    @GetMapping("/inner/dr/getNoSecret")
    Integer getNoSecret(@RequestParam("doctorId") Long doctorId) throws BusinessException;

    /**
     * 获取免签信息
     * @param doctorId 医生id
     * @return
     * @throws BusinessException
     */
    @GetMapping("/inner/dr/getNoSecretInfo")
    EsignNoSecretBO getNoSecretInfo(@RequestParam("doctorId") Long doctorId) throws BusinessException;

    /**
     * 设置免密预签署
     * 
     * @param doctorId
     * @return
     * @throws BusinessException
     */
    @PostMapping("/inner/dr/preNoSecret")
    PreSignResultBO preNoSecret(@RequestParam("doctorId") Long doctorId) throws BusinessException;

    /**
     * 设置免密
     * 
     * @param paramBO
     * @return
     * @throws BusinessException
     */
    @PostMapping("/inner/dr/setNoSecret")
    void setNoSecret(@RequestBody NoSecretParamBO paramBO) throws BusinessException;

    @GetMapping("inner/dr/saveSealImg")
    void saveSealImg(@RequestParam("doctorId") Long doctorId, @RequestParam("sealImg") String sealImg) throws BusinessException;

    /**
     * 更新esign认证状态
     * @param doctorId
     */
    @PostMapping("/inner/dr/setAuthStatus")
    void setAuthStatus(@RequestParam("doctorId") Long doctorId, @RequestParam("status") Integer status);

    /**
     * 获取用户是否注册过ca账户
     * @param number
     * @return
     */
    @GetMapping("inner/dr/getAccountByDoctorIdAndIdNo")
    Boolean getAccountByDoctorIdAndIdNo(@RequestParam("doctorId") Long doctorId,@RequestParam("number") String number);

    /**
     * 获取医生数字证书
     * 
     * @param doctorId
     * @return
     * @throws BusinessException
     */
    @GetMapping("inner/dr/getDigitalCertificate")
    DigitalCertificateBO getDigitalCertificate(@RequestParam("doctorId") Long doctorId) throws BusinessException;

    /**
     * 检查该医生身份证号是否已实名
     * 
     * @param doctorId
     * @param idCard
     * @throws BusinessException
     */
    @GetMapping("inner/dr/checkDoctorRealname")
    void checkDoctorRealname(@RequestParam("doctorId") Long doctorId, @RequestParam("idCard") String idCard)
        throws BusinessException;
}
